#version 330 core

uniform mat4 mv_matrix;
uniform mat4 proj_matrix;

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;

out vec3 vVaryingTexCoord;

void main(void)
{
    mat4 mInverseCamera = inverse(mv_matrix);
    vec4 vEyeNormal = mv_matrix * vec4(/*-*/normal, 1.0);

    vec4 vVert = mv_matrix * vec4(position, 1.0);
    vec4 vEyeVertex = normalize(vVert);
    vec4 vCoords = reflect(vEyeVertex, vEyeNormal);

    vCoords = mInverseCamera * vCoords;
    vVaryingTexCoord = normalize(vCoords.xyz);

    gl_Position = proj_matrix * vVert;
}
